package com.aaa.rent.service.impl;/**
 * Date:2023/3/1
 * Author：臣哥哥
 * Description:
 */

import com.aaa.entity.Brand;
import com.aaa.rent.dao.BrandDao;
import com.aaa.rent.service.BrandService;
import com.aaa.vo.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author     ：Xiaochen
 * @date       ：Created in 2023/3/1 11:30
 * @description：
 * @modified By：
 * @version:
 */
@Service
public class BrandServiceImpl implements BrandService {
    @Autowired
    private BrandDao brandDao;

    /**
     * 模糊分页查询
     * @param currentPage
     * @param pageSize
     * @param brand
     * @return
     */
    @Override
    public Result selectAll(Integer currentPage, Integer pageSize, Brand brand) {
        PageHelper.startPage(currentPage,pageSize);
        List<Brand> brands = brandDao.selectAll(brand);
        PageInfo<Brand> brandPageInfo = new PageInfo<>(brands);
        System.out.println("users ==================== " + brandPageInfo);
        return new Result(2000,"成功",brandPageInfo);
    }


    /**
     * 修改
     * @param brand
     * @return
     */
    @Override
    public Result update(Brand brand) {
        int i = brandDao.updateById(brand);
        return new Result(2000,"成功",i);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @Override
    public Result delete(Integer id) {
        int i = brandDao.deleteById(id);
        return new Result(2000,"成功",i);
    }

    /**
     * 添加
     * @param brand
     * @return
     */
    @Override
    public Result insert(Brand brand) {
        int insert = brandDao.insert(brand);
        return new Result(2000,"成功",insert);
    }

    @Override
    public Result selectBrand() {
        return new Result(2000,"成功",brandDao.selectList(null));
    }
}